<?php


namespace support\exception;


use Exception;
use support\constants\RespCode;
use Webman\Http\Request;
use Webman\Http\Response;

class BadException extends Exception
{
    public function render(Request $request): ?Response
    {
        $code = $this->getCode();
        $msg = $this->getMessage();
        return json([
            'success' => false,
            'message' => $msg ?: "操作失败!!!",
            'code' => $code ?: RespCode::ERROR,
            'data' => [],
        ]);
    }
}
